<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/content/variable.jsp" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <%@ include file="/content/head.jsp" %>
</head>
<body>
<div class="row">
    <div class="col-md-12">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">添加内容</h3>
            </div>
            <form id="addInfo" class="form-horizontal" role="form" onsubmit="javascript:saveInfo();">
                <div class="box-body">
                    <div class="form-group">
                        <label for="title" class="col-sm-2 control-label">标题：</label>
                        <div class="col-sm-8 ">
                            <input type="text" id="title" class="form-control" name="title"
                                   placeholder="标题">
                        </div>
                    </div>
                    <br>
                    <div class="form-group">
						<label for="topicType" class="col-sm-1 control-label">分类：</label>
						<div class="col-sm-8 ">
                            <select id="topicType" name="topicType" class="form-control select2">
                               <option value="1" selected='selected'>精选</option>
                               <option value="2">热门</option>
                            </select>
                        </div>
                    </div>
                    <br>
                    <div class="form-group">
                        <label for="love" class="col-sm-2 control-label">点赞：</label>
                        <div class="col-sm-8 ">
                            <input type="text" id="love" class="form-control" name="love"
                                   placeholder="点赞">
                        </div>
                    </div>
                    <br>
                    <div class="form-group">
                        <label for="comment" class="col-sm-2 control-label">评论：</label>
                        <div class="col-sm-8 ">
                            <input type="text" id="comment" class="form-control" name="comment"
                                   placeholder="评论">
                        </div>
                    </div>
                    <br>
                    <div class="form-group">
                        <label for="label" class="col-sm-2 control-label">标签：</label>
                        <div class="col-sm-8 ">
                            <input type="text" id="label" class="form-control" name="label"
                                   placeholder="标签">
                        </div>
                    </div>               
                    <br>
                    <div class="col-md-offset-5 col-md-9">
                        <button type="submit" class="btn btn-success">确定</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- /.row -->
<%@ include file="/content/js.jsp" %>
<script type="text/javascript">
function saveInfo(){
	var title = $("#title").val();
	var label = $("#label").val();
	var love = $("#love").val();
	var comment= $("#comment").val();
	var topicType= $("#topicType").val();
	$.ajax({
		type:"post",
		async: false,
		url:"<%=path%>/topic/addTopicSave",
		data:{title:title,
			label:label,
			love:love,
			comment:comment,
			topicType:topicType},
		dataType:"json",
		success: function(data){
			if (data.missage == "success") {
                modalMsg("新增成功", "success");
                window.parent.location.reload();
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }else if(data.missage == "error"){
            	 modalMsg("新增失败", "error");
            }else{
            	 modalMsg("更新失败", "error");
            }
		}
	});
}
</script>
</body>
</html>